/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.wors.android.custom.rideshare2;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author 231260
 */
public class KalendarData {
	
	public ArrayList<Date> data;
	public ArrayList<Integer> days;
	public ArrayList<Boolean> colors;
	public Calendar kalendar;
	
	public KalendarData(Date datum)
	{
		data = new ArrayList<Date>(42);
		days = new ArrayList<Integer>(42);
		colors = new ArrayList<Boolean>(42);
		kalendar = Calendar.getInstance();
		
		kalendar.setTime(datum);
		
		int year = kalendar.get(Calendar.YEAR);
		int month = kalendar.get(Calendar.MONTH);
		int day = kalendar.get(Calendar.DAY_OF_MONTH);
		/*
		kalendar.set(2011, 11, 13);
		datum = kalendar.getTime();
		*/
		int day_count = kalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
		int old_week_day_count = KalendarTools.getOldDaysInFirstWeek(datum);
		int old_month_day_count = KalendarTools.getOldMonthDayCount(datum);
		int next_week_day_count = KalendarTools.getNextDaysInLastWeek(datum);
		
		int[] day_values = new int[42];
		Date[] date_values = new Date[42];
		Boolean[] col_values = new Boolean[42];
		
		kalendar.add(Calendar.MONTH, -1);
		for (int i=1;i <= old_week_day_count; i++)
		{
			int den = old_month_day_count-(old_week_day_count-i);
			kalendar.set(Calendar.DAY_OF_MONTH, den);
			day_values[i-1] = den;
			date_values[i-1] = kalendar.getTime();
			col_values[i-1] = false;
		}
		
		kalendar.add(Calendar.MONTH, +1);
		for (int i=1;i <= day_count;i++)
		{
			int den = i;
			kalendar.set(Calendar.DAY_OF_MONTH, den);
			day_values[old_week_day_count+i-1] = i;
			date_values[old_week_day_count+i-1] = kalendar.getTime();
			col_values[old_week_day_count+i-1] = true;
		}
		
		kalendar.add(Calendar.MONTH, +1);
		for (int i=1;i <= 42-old_week_day_count-day_count; i++)
		{
			int den = i;
			kalendar.set(Calendar.DAY_OF_MONTH, den);
			day_values[old_week_day_count+day_count+i-1] = i;
			date_values[old_week_day_count+day_count+i-1] = kalendar.getTime();
			col_values[old_week_day_count+day_count+i-1] = false;
		}
		
		//day_values[0] = first_day_position;
		
		for (int i=0; i < 42; i++)
		{
			data.add(date_values[i]);
			days.add(Integer.valueOf(day_values[i]));
			colors.add(col_values[i]);
		}
	}
}
